<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<html:html>
<head>
<title><bean:message key="adminaccounts.title"/></title>
<link rel="stylesheet" href="<%=request.getContextPath() %>/default.css" type="text/css">
<html:base/>
</head>
<body>

<div id="header">
	<div id="logo">
		<h1>
			<html:img width="40" src="../images/EMPTY.GIF"/>
			<html:link page="/pages/home.jsp">Textbook Crossroads</html:link>
		</h1>
		<h2>Team 14 - LoneTree</h2>
	</div>
	<div id="menu">
		<ul>
			<li class="active"><html:link page="/pages/admindashboard.jsp">Dashboard</html:link></li>
			<li><html:link page="/pages/books.jsp">Books</html:link></li>
			<li><html:link page="/pages/courses.jsp">Courses</html:link></li>
			<li><html:link page="/pages/about.jsp">About</html:link></li>
			<li class="logon"><html:link action="/logout">LogOut</html:link></li> 
		</ul>
	</div>
</div>

<logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
  <font color="red">
    ERROR:  Application resources not loaded -- check servlet container
    logs for error messages.
  </font>
</logic:notPresent>

<div id="content">
	<div id="sidebar">
			<div id="categories">
			<div id="archives" class="boxed">
				<h2>Admin Actions</h2>
				<div class="content">
					<ul>
			    		<li><html:link href="bookadmin.jsp"><bean:message
			            key="adminbook.link"/></html:link></li>
			            
			            <li><html:link action="/AdminCourses"><bean:message
			            key="admincourses.link"/></html:link></li>
			            
			            <li><html:link action="/AdminAccounts"><bean:message
			            key="adminaccounts.link"/></html:link></li>
			            
			            <li><html:link action="/AdminComments"><bean:message
			            key="admincomments.link"/></html:link></li>
					</ul>
				</div>
			</div>
		</div>
	</div>

	<div id="posts">
		<div class="post">
			<h2 class="title"><bean:message key="adminaccounts.heading"/></h2>
			<div class="meta">
				<p class="date">List of current users:</p>
			</div>
			<div class="story">
				<html:form action="/CreateUser" focus="username">
				    <table border="0" width="100%">

				            <tr>
				            	<td>
				                <bean:message key="prompt.userId"/>:
				                <html:text property="username" size="16" maxlength="18"/>
				                </td>
				            </tr>				

				            <tr>
				            	<td>
				            	<html:radio property="admin" value="no"/>
				            	<bean:message key="prompt.usertype1"/>
				                <html:radio property="admin" value="yes"/>				                
				                <bean:message key="prompt.usertype2"/>
								</td>
				            </tr>
				            	<td>
				                <html:submit><bean:message key="adminaccounts.adduser.button" /></html:submit>
				                </td>				        
				        	<tr>
				        		
				        </table><br/>

				        <tr>
				        <logic:present name="allusers">
				        <logic:notEmpty name="allusers">
				<table width="100%">
				        <logic:iterate id="usr" name="allusers" indexId="cnt">
				        <tr>
				<td width="50"><html:link action="/PrepForUserUpdate" paramName="usr" paramProperty="username" paramId="username">
						  		<bean:write name="usr" property="username" />
						  		</html:link>
						  	</td><td width="50">&nbsp;</td>
						  	<td>
				                <logic:equal value="true" name="usr" property="admin">
				                admin user
				                </logic:equal>
				                <logic:equal value="false" name="usr" property="admin">
				                regular user
				                </logic:equal>
				            </td>
				            <td>
				                <html:link action="/RemoveUser" paramName="usr" paramProperty="username" paramId="username">
				                Remove User</html:link>
				            </td>
				            </tr>
						</logic:iterate>
				</table>
						</logic:notEmpty>
						<logic:empty name="allusers">
					    Database search did not return any users
					    </logic:empty>
					    
						</logic:present>
				
						<logic:notPresent name="allusers">
						No User list in scope
						</logic:notPresent>
				        </tr>
				</html:form>
			</div>
		</div>
	</div>
</div>

<div id="footer">
	<p id="copy">&copy;2007 LoneTree.</p>
	<p> (Andrew Lee | Bojan Martin | Dimeji Omikunle | Minghui Yu)</p>
</div>
</body>
</html:html>